package com.haozhen.controller;

import com.haozhen.component.DataSourceChangeListerner;
import com.haozhen.component.DataSourceChangeServer;
import com.haozhen.entity.DataSourceLinkInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author haozhen
 * @email haozh@ync1.com
 * @date 2020/10/24  13:27
 */
@RestController
@RequestMapping("dynamicDataSourceController")
public class DynamicDataSourceController {

    @Autowired
    private DataSourceChangeServer dataSourceChangeServer;

    @Autowired
    private DataSourceChangeListerner dataSourceChangeListerner;

    @PostMapping(value = "changeDataSource")
    public String changeDataSource(@RequestBody DataSourceLinkInfo dataSourceLinkInfo){
        dataSourceChangeServer.registerDataSource(dataSourceLinkInfo);
        return "修改成功";
    }
    @GetMapping("getSysUserInfo")
    public List<Map<String,String>> getSysUserInfo(){
        return dataSourceChangeListerner.testDataSource();
    }
}
